bitkeeper revision 1.317 (3f0c0840dkPeEx-FKvCNpuxOGrbQAw)
authorsos22@labyrinth.cl.cam.ac.uk <sos22@labyrinth.cl.cam.ac.uk>
Wed, 9 Jul 2003 12:19:12 +0000 (12:19 +0000)
committersos22@labyrinth.cl.cam.ac.uk <sos22@labyrinth.cl.cam.ac.uk>
Wed, 9 Jul 2003 12:19:12 +0000 (12:19 +0000)
Why was this a spinlock?  We're protecting against other userspace
processes trying to open /proc/xeno/domains, not the kernel.
Switch to using a semaphore.

xenolinux-2.4.21-sparse/arch/xeno/drivers/dom0/dom0_core.c

index 29fc9c4fcc3a410ee8b74ca0dca6c5545013bdc4..b2d3c8d05765d0f3abdd1f21b2f424dd4e711611 100644 (file)
@@ -189,7 +189,7 @@ static int dom0_cmd_write(struct file *file, const char *buffer, size_t size,
 
 static dom0_op_t proc_domains_op;
 static int proc_domains_finished;
-static rwlock_t proc_xeno_domains_lock = RW_LOCK_UNLOCKED;
+static DECLARE_MUTEX(proc_xeno_domains_lock);
 
 static void *xeno_domains_next(struct seq_file *s, void *v, loff_t *pos)
 {
@@ -213,7 +213,7 @@ static void *xeno_domains_start(struct seq_file *s, loff_t *ppos)
 { 
     loff_t pos = *ppos;
   
-    write_lock (&proc_xeno_domains_lock);
+    down (&proc_xeno_domains_lock);
     proc_domains_op.cmd = DOM0_GETDOMAININFO;
     proc_domains_op.u.getdominfo.domain = 0;
     (void)HYPERVISOR_dom0_op(&proc_domains_op);
@@ -229,7 +229,7 @@ static void *xeno_domains_start(struct seq_file *s, loff_t *ppos)
 
 static void xeno_domains_stop(struct seq_file *s, void *v)
 { 
-    write_unlock (&proc_xeno_domains_lock);
+    up(&proc_xeno_domains_lock);
 }
 
 static int xeno_domains_show(struct seq_file *s, void *v)
@@ -327,7 +327,6 @@ static unsigned long handle_dom0_cmd_mapdommem(unsigned long data)
     return -EFAULT;
   /* This seems to be assuming that the root of the page table is in
      the first frame of the new domain's physical memory? */
-  /* XXX what happens if userspace forgets to do the unmap? */
 
   addr = direct_mmap(argbuf.start_pfn << PAGE_SHIFT,
                     argbuf.tot_pages << PAGE_SHIFT,
@@ -357,14 +356,14 @@ static int handle_dom0_cmd_dopgupdates(unsigned long data)
     return -EFAULT;
 
   /* argbuf.pgt_update_arr had better be direct mapped... */
-  return HYPERVISOR_pt_update(argbuf.pgt_update_arr,
+  /* XXX check this */
+  return HYPERVISOR_pt_update((void *)argbuf.pgt_update_arr,
                              argbuf.num_pgt_updates);
 }
 
 static int dom0_cmd_ioctl(struct inode *inode, struct file *file,
                          unsigned int cmd, unsigned long data)
 {
-  printk("dom0_cmd ioctl command %x\n", cmd);
   switch (cmd) {
   case IOCTL_DOM0_CREATEDOMAIN:
     return handle_dom0_cmd_createdomain(data);
@@ -375,8 +374,10 @@ static int dom0_cmd_ioctl(struct inode *inode, struct file *file,
   case IOCTL_DOM0_DOPGUPDATES:
     return handle_dom0_cmd_dopgupdates(data);
   default:
-    printk("Unknown dom0_cmd ioctl!\n");
-    return -EINVAL;
+    return -ENOTTY; /* It isn't obvious why this is the correct error
+                      code when an ioctl isn't recognised, but it
+                      does appear to be what's used in the rest of
+                      the kernel. */
   }
 }